
const { ccclass, property } = cc._decorator;

@ccclass
export class UIManager extends cc.Component {
    private _panelDict: any = {}
    private _loadingPanelDict: any = {}

    private _arrPopupDialog: any = []

    private static _instance: UIManager;
    public static get Instance() {
        if (!this._instance) {
            this._instance = new UIManager();
        }

        return this._instance;
    }
    protected onLoad(): void {
        UIManager._instance = this;
        cc.game.addPersistRootNode(this.node);
    }

    public static ShowTip(Txt: string) {
        let pre = UIManager.Instance.node.getChildByName("弹窗");
        pre.active = true;
        pre.getChildByName("文本").getComponent(cc.Label).string = Txt;
        UIManager.Instance.scheduleOnce(() => {
            pre.active = false;
        }, 1.5)
    }
    public static AudioPlay(name: string, CallBack?: Function) {
        cc.resources.load("Audio/" + name, cc.AudioClip, (err, event) => {
            if (err) {
                console.log("没有找到音效文件" + name);
                return;
            }
            let AudioId = cc.audioEngine.playEffect(event, false);
            if (CallBack) {
                cc.audioEngine.setFinishCallback(AudioId, CallBack);
            }
        })
    }
}